apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: {{ namespace }}
  name: {{ user }}
rules:
- apiGroups: ["", "extensions", "apps"]
  resources: ["*"]
  verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ user }}
  namespace: {{ namespace }}
subjects:
- kind: User
  name: {{ user }}
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: {{ user }}
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ user }}-cluster
rules:
- apiGroups: [""]
  resources: ["nodes", "services", "pods"]
  verbs: ["list", "watch", "get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ user }}-cluster
subjects:
- kind: User
  name: {{ user }}
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: {{ user }}-cluster
  apiGroup: rbac.authorization.k8s.io
